package com.shujia.utils

import java.text.SimpleDateFormat

object DateUtil {

  def diff(date1: String, data2: String): Long = {
    //将时间字符串转换成时间戳
    val format = new SimpleDateFormat("yyyyMMddHHmmss")

    //获取时间戳
    val time1: Long = format.parse(date1).getTime
    val time2: Long = format.parse(data2).getTime

    Math.abs(time1 - time2) / 1000
  }

  def main(args: Array[String]): Unit = {
    println(diff("20180503100029", "20180503100050"))
  }

}
